all: build-32 build-64

build-64: clean
	gcc -g -O2 -Wall -D_GNU_SOURCE -c init.c -fPIC -DPIC -o init.o
	gcc -g -O2 -Wall -D_GNU_SOURCE -c wrapper.c -fPIC -DPIC -o wrapper.o
	gcc -g -O2 -Wall -D_GNU_SOURCE -c simics.c -fPIC -DPIC -o simics.o
	gcc -g -O2 -Wall -D_GNU_SOURCE -c timeclient.c -fPIC -DPIC -o timeclient.o

	gcc -shared -avoid-version -ldl -lrt -o timelib-64.so init.o wrapper.o simics.o timeclient.o

build-32: clean
	gcc -m32 -g -O2 -Wall -D_GNU_SOURCE -c init.c -fPIC -DPIC -o init.o
	gcc -m32 -g -O2 -Wall -D_GNU_SOURCE -c wrapper.c -fPIC -DPIC -o wrapper.o
	gcc -m32 -g -O2 -Wall -D_GNU_SOURCE -c simics.c -fPIC -DPIC -o simics.o
	gcc -m32 -g -O2 -Wall -D_GNU_SOURCE -c timeclient.c -fPIC -DPIC -o timeclient.o

	gcc -m32 -shared -avoid-version -ldl -lrt -o timelib-32.so init.o wrapper.o simics.o timeclient.o



clean:
	-rm *.o


install:
	cp timelib-32.so /home/qostjoa/git/moshell/commonjars/lib/lib/timelib.so
	cp timelib-64.so /home/qostjoa/git/moshell/commonjars/lib/lib64/timelib.so