summaryrefslogtreecommitdiff
blob: 10bda2a476a8dc8c45ef68b74d7dd5ab9c96e223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--- a/example/Makefile.in
+++ b/example/Makefile.in
@@ -1,7 +1,11 @@
-cc=@CC@
 DEFINES=@DEFINES@
+CFLAGS=$(DEFINES) $(OPTFLAGS) -I..
+BINS = sign test new
 
-all:
-	${CC} ${DEFINES} -I.. -Wall -O3 sign.c -o sign ../libmelf.a
-	${CC} ${DEFINES} -I.. -Wall -O3 test.c -o test ../libmelf.a
-	${CC} ${DEFINES} -I.. -Wall -O3 new.c -o new ../libmelf.a
+%: %.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ -o $@ -L.. -lmelf
+
+all: $(BINS)
+
+clean:
+	-rm -f $(BINS)
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,25 +1,23 @@
-CC=gcc
-
 STATICBIN=libmelf.a
 DYNAMICBIN=libmelf.so
 DEBUG=
 DEFINES=@DEFINES@ -DMELF_COMP
 INCLUDES=-I.
 PREFIX=@PREFIX@
-CFLAGS=${DEBUG} ${DEFINES} ${INCLUDES} -Wall -O3 -fPIC
-LFLAGS=${DEBUG} ${DEFINES} ${INCLUDES} -Wall -O3 -o
+CFLAGS=${DEBUG} ${DEFINES} ${INCLUDES} ${OPTFLAGS}
+LFLAGS=${DEBUG} ${DEFINES} ${INCLUDES} ${OPTFLAGS} -o
 LIBS=
 OBJS=melf.o melf_dynamic.o melf_elf.o melf_list.o melf_note.o melf_program.o melf_reloc.o \
 	  melf_res.o melf_section.o melf_string.o melf_symbol.o melf_symbolTable.o
 
-all: ${OBJS}
-	ar rc ${STATICBIN} ${OBJS} && ranlib ${STATICBIN}
-	@SHAREDEXEC@
-	cd example && make
-	cd tools && make
+all: ${STATICBIN} ${DYNAMICBIN}
+	$(MAKE) -C example
+	$(MAKE) -C tools
 
-*.c.${O}:
-	${CC} ${CFLAGS} $*.c
+${STATICBIN}: ${OBJS}
+	$(AR) rc ${STATICBIN} ${OBJS} && $(RANLIB) ${STATICBIN}
+${DYNAMICBIN}: ${OBJS}
+	@SHAREDEXEC@
 
 clean:
 	rm -f *.o ${STATICBIN} ${DYNAMICBIN} example/test example/new example/sign tools/elfres config.*
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -1,8 +1,11 @@
-cc=@CC@
 DEFINES=@DEFINES@
+CFLAGS=$(DEFINES) $(OPTFLAGS) -I..
+BINS=elfres
 
-all:
-	${CC} ${DEFINES} -I.. -Wall -O3 elfres.c -o elfres ../libmelf.a
+%: %.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ -o $@ -L.. -lmelf
+
+all: $(BINS)
 
 clean:
 	rm -f elfres