Skip to content

Instantly share code, notes, and snippets.

@doi-t
Created January 29, 2014 20:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doi-t/8695964 to your computer and use it in GitHub Desktop.
Save doi-t/8695964 to your computer and use it in GitHub Desktop.
makeでライブラリ(.a)のビルドを管理するサンプル(gccとg++の混在ver)
#include "hello.h"
int
print_hello(void)
{
printf("hello gnu ar world !!\n");
return 0;
}
#ifndef ___hello
#define ___hello
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
int print_hello(void);
#ifdef __cplusplus
}
#endif
#endif //___hello
CC := gcc
RM := rm -f
CFLAGS := -Wall
CXXFLAGS := -Wall
programs := run
.PHONY: all
all: $(programs)
$(programs): libhello.a
libhello.a: libhello.a(hello.o)
hello.o: hello.h
.PHONY: clean
clean:
$(RM) *.o *.a $(programs)
#include "hello.h"
int
main(int argc, char **argv)
{
print_hello();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment