all: lib1stclass.a libb1stclass.so lib1stclass_cxx.a lib1stclass_cxx.so t/test

lib1stclass_cxx.a: host2ip_cxx.o is_num_cxx.o remove_path_cxx.o remove_not_file_char_cxx.o rmkdir_cxx.o 1stclass.hpp safe_strcat_cxx.o shmf_cxx.o itoa_cxx.o reverse_char_cxx.o rel2abs_cxx.o
	ar rvs lib1stclass_cxx.a host2ip_cxx.o is_num_cxx.o remove_path_cxx.o remove_not_file_char_cxx.o rmkdir_cxx.o safe_strcat_cxx.o shmf_cxx.o itoa_cxx.o reverse_char_cxx.o rel2abs_cxx.o
	ranlib lib1stclass_cxx.a;

lib1stclass_cxx.so: host2ip_cxx.o is_num_cxx.o remove_path_cxx.o remove_not_file_char_cxx.o rmkdir_cxx.o 1stclass.hpp safe_strcat_cxx.o shmf_cxx.o reverse_char_cxx.o rel2abs_cxx.o
	g++ -shared -fPIC -o lib1stclass_cxx.so host2ip_cxx.o is_num_cxx.o remove_path_cxx.o remove_not_file_char_cxx.o rmkdir_cxx.o safe_strcat_cxx.o shmf_cxx.o reverse_char_cxx.o rel2abs_cxx.o

lib1stclass.a: host2ip.o rmkdir.o safe_strcat.o is_num.o itoa.o remove_path.o remove_not_file_char.o shmf.o reverse_char.o rel2abs.o
	ar rvs lib1stclass.a host2ip.o itoa.o rmkdir.o safe_strcat.o is_num.o remove_path.o remove_not_file_char.o shmf.o reverse_char.o rel2abs.o
	ranlib lib1stclass.a;

libb1stclass.so: host2ip.o rmkdir.o safe_strcat.o is_num.o itoa.o remove_path.o remove_not_file_char.o shmf.o reverse_char.o rel2abs.o
	g++ -shared -fPIC -o lib1stclass.so host2ip.o itoa.o rmkdir.o safe_strcat.o is_num.o remove_path.o remove_not_file_char.o shmf.o reverse_char.o rel2abs.o

host2ip.o: host2ip.c
	gcc -Wall -O3 -finline-functions -c host2ip.c;

host2ip_cxx.o: host2ip.c
	g++ -Wall -O3 -finline-functions -o host2ip_cxx.o -c host2ip.c;

is_num.o: is_num.c
	gcc -Wall -O3 -finline-functions -c is_num.c;

is_num_cxx.o: is_num.c
	g++ -Wall -O3 -finline-functions -o is_num_cxx.o -c is_num.c;

itoa.o: itoa.c
	gcc -Wall -O3 -finline-functions -c itoa.c

itoa_cxx.o: itoa.c
	g++ -Wall -O3 -finline-functions -o itoa_cxx.o -c itoa.c

reverse_char.o: reverse_char.c;
	gcc -Wall -O3 -finline-functions -c reverse_char.c;

reverse_char_cxx.o: reverse_char.c;
	g++ -Wall -O3 -finline-functions -o reverse_char_cxx.o -c reverse_char.c;

remove_not_file_char.o: remove_not_file_char.c;
	gcc -Wall -O3 -finline-functions -c remove_not_file_char.c;

remove_not_file_char_cxx.o: remove_not_file_char.c;
	g++ -Wall -O3 -finline-functions -o remove_not_file_char_cxx.o -c remove_not_file_char.c;

remove_path.o: remove_path.c
	gcc -Wall -O3 -finline-functions -c remove_path.c;

remove_path_cxx.o: remove_path.c
	g++ -Wall -O3 -finline-functions -o remove_path_cxx.o -c remove_path.c;

rel2abs.o: rel2abs.c
	gcc -Wall -O3 -finline-functions -c rel2abs.c;

rel2abs_cxx.o: rel2abs.c
	g++ -Wall -O3 -finline-functions -o rel2abs_cxx.o -c rel2abs.c;

rmkdir.o: rmkdir.c
	gcc -Wall -O3 -finline-functions -c rmkdir.c;

rmkdir_cxx.o: rmkdir.c
	g++ -Wall -O3 -finline-functions -o rmkdir_cxx.o -c rmkdir.c;

safe_strcat.o: safe_strcat.c
	gcc -Wall -O3 -finline-functions -c safe_strcat.c;

safe_strcat_cxx.o: safe_strcat.c
	g++ -Wall -O3 -finline-functions -o safe_strcat_cxx.o -c safe_strcat.c;

shmf.o: shmf.c
	gcc -Wall -O3 -finline-functions -c shmf.c;

shmf_cxx.o: shmf.c
	g++ -Wall -O3 -finline-functions -o shmf_cxx.o -c shmf.c;

t/test: t/test.cpp lib1stclass_cxx.a lib1stclass.a;
	g++ -Wall -O3 -finline-functions -o t/test.o -c t/test.cpp;
	g++ -o t/test t/test.o lib1stclass_cxx.a lib1stclass.a;
	chmod 755 t/test;


install:
	mkdir -p /usr/local/lib;
	cp lib1stclass.a /usr/local/lib;
	cp lib1stclass.so /usr/local/lib;
	cp lib1stclass_cxx.a /usr/local/lib;
	cp lib1stclass_cxx.so /usr/local/lib;
	cp 1stclass.h /usr/local/include;
	cp 1stclass.hpp /usr/local/include;
	perl add_version.pl;

clean:
	rm *.o -f *.o;
	rm *.a -f *.a;
	rm *.so -f *.so;
	rm t/test -f test;
	rm t/*.o -f t/*.o;

real_clean:
	rm t/*~ -f t/*~;
	rm *~ -f *~;
	rm *.o -f *.o;
	rm *.a -f *.a;
	rm *.so -f *.so;
	rm t/test -f test;
	rm t/*.o -f t/*.o;
	rm *.tar.gz -f *.tar.gz;

test:
	t/test;

dist:
	perl add_version.pl --release;
