-$(TARGET): main.o btree.o clave_fija.o btree_data.o
- g++ -o $(TARGET) main.o btree.o clave_fija.o btree_data.o
+CXXFLAGS += $(PROF)
+
+BTREE_COMMON=btree.o clave_fija.o btree_data.o clave_variable.o random.o
+
+all: $(TARGETS)
+
+btree: main.o $(BTREE_COMMON)
+ g++ $(PROF) -o btree main.o $(BTREE_COMMON)
+
+btree_var: main_var.o $(BTREE_COMMON)
+ g++ $(PROF) -o btree_var main_var.o $(BTREE_COMMON)
+
+libbtree.a: $(BTREE_COMMON)
+ $(AR) cru libbtree.a $(BTREE_COMMON)