summaryrefslogblamecommitdiffstats
path: root/Makefile
blob: ceed6ebeeb2d3d991b1aa52bdc96f1c26d07cb9f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                                                                                                    
                            








                                                            



                                                                                      


                         
CFILES 		:= $(wildcard *.c)
OFILES		:= $(patsubst %.c,%.o,$(CFILES))

SHARED	?= 1
STATIC	?= 0

CC	?=	gcc
AR	?= 	ar

WARNS	?= -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -Wnull-dereference -Wdouble-promotion -Wshadow -Wcast-align
CFLAGS	?= $(WARNS) -L$(shell pwd)
OUT		:= libdiheap

.PHONY: all
all: $(OFILES)
ifeq ($(SHARED),1)
	$(CC) -shared $(CFLAGS) -o $(OUT).so -fPIC $(CFILES)
endif
ifeq ($(STATIC),1)
	$(AR) rcs $(OUT).a $^
endif
ifeq ($(TEST),1)
	$(CC) -I$(shell pwd) -L. -l:$(OUT).so -o testprg test/main.c -g
	export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(shell pwd) ; perf stat -B ./testprg
endif

%.o:%.c
	$(CC) -c -o $@ $<