Browse code

more automated Makefile; to be replaced by ser Makefiles later

Jiri Kuthan authored on 20/11/2001 01:56:05
Showing 1 changed files
... ...
@@ -1,26 +1,49 @@
1
-CC		= g++
2
-cc		= gcc
3
-CCFLAGS 	= -c
4
-TABLE_DIR          = table
5
-INCLUDE 	= -include $(TABLE_DIR)/h_table.h
6
-LIBS		= -lpthread
1
+#common
2
+CC=gcc
3
+LD=gcc
4
+CFLAGS=-O2 -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes
5
+LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
6
+LEX=flex
7
+YACC=bison
8
+YACC_FLAGS=-d -b cfg
9
+# on linux and freebsd keep it empty (e.g. LIBS= )
10
+# on solaris add -lxnet (e.g. LIBS= -lxnet)
11
+LIBS=-lfl -ldl
7 12
 
8
-all: build link
13
+MKDEP=gcc -M
9 14
 
10
-build:  $(TABLE_DIR)/table.o  tm.o
15
+ALLDEP=Makefile
11 16
 
12
-link:  tm
17
+auto_gen=
18
+sources= $(filter-out $(auto_gen), $(wildcard *.c)) $(auto_gen)
19
+objs= $(sources:.c=.o)
20
+depends= $(sources:.c=.d)
13 21
 
14
-$(TABLE_DIR)/table.o: Makefile $(TABLE_DIR)/hash_func.c $(TABLE_DIR)/h_table.c $(TABLE_DIR)/h_table.h $(TABLE_DIR)/semaphore.c $(TABLE_DIR)/timer.c
15
-	$(cc)  $(CCFLAGS)  $(TABLE_DIR)/h_table.c -o $@
22
+NAME=tm
16 23
 
17
-tm.o: Makefile tm.c
18
-	$(cc)  $(CCFLAGS)  $(INCLUDE) tm.c -o $@
24
+ALLDEP=Makefile
19 25
 
20
-tm: Makefile tm.o $(TABLE_DIR)/table.o
21
-	$(cc)  tm.o $(TABLE_DIR)/table.o $(LIBS)  -o $@
26
+LDFLAGS=-O2 -shared
27
+LIBS=
22 28
 
23
-clean:
24
-	rm -f  $(TABLE_DIR)/*.o || return 0
25
-	rm -f  *.o || return 0
26
-	rm -f tm  || return 0
29
+ifeq ($(ARCH), SunOS)
30
+LDFLAGS=-O2 -G
31
+endif
32
+
33
+#implicit rules
34
+%.o:%.c $(ALLDEP)
35
+	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
36
+
37
+%.d: %.c
38
+	$(MKDEP) $< >$@
39
+
40
+
41
+$(NAME): $(objs)
42
+	$(LD) $(LDFLAGS) $(objs) $(LIBS) -o $(NAME)
43
+
44
+
45
+.PHONY: all
46
+all: $(NAME)
47
+
48
+.PHONY: dep
49
+dep: $(depends)