#
#       Makefile pour la librairie Nilorea
#

VPATH=src/
CC := gcc
CFLAGS += -DLINUX -W -Wall -pedantic -std=gnu99 -g -Iinclude/ `pkg-config --cflags --libs allegrogl allegro jpgalleg loadpng logg`

CBIDIR= $(HOME)/include
CBLDIR= $(HOME)/lib
LIBNAME= libnilorea.a
IHDR=$(SRC:%.c=$(CBIDIR)/%.h) $(CBIDIR)/nilorea.h

LIBNAME= libnilorea.a
LIBNAME_D= libnilorea_d.a

COPY=cp
RM=rm


SRC= n_common.c n_log.c n_exceptions.c n_str.c n_list.c n_hash.c n_thread_pool.c n_network.c n_network_msg.c n_gfx.c n_3d.c n_iso_engine.c lexmenu.c n_games.c n_particles.c

OBJECTS=$(SRC:%.c=obj/%.o) 

HDR=$(SRC:%.c=%.h) nilorea.h 

IHDR=$(SRC:%.c=$(CBIDIR)/%.h) $(CBIDIR)/nilorea.h

obj/%.o: src/%.c
	$(CC) $(CFLAGS) -c $< -o $@

main: $(OBJECTS)
	$(AR) -r $(LIBNAME) $(OBJECTS)

debug:
	LIBNAME=$(LIBNAME_D)
	CFLAGS= "-DDEBUGMODE -g" $(MAKE)

clean:
	$(RM) *.a
	$(RM) $(OBJECTS)

install: main
	$(COPY) include/*.h $(CBIDIR)/nilorea/ 
	$(COPY) $(LIBNAME) $(CBLDIR)/$(LIBNAME) 
	mv "$(CBIDIR)/nilorea/nilorea.h" "$(CBIDIR)"

uninstall: clean
