Skip to content

Commit

Permalink
Adding simple makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
TeraHz committed Dec 31, 2012
1 parent ea3e181 commit 5f59296
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@
<option id="gnu.cpp.compiler.option.debugging.level.2118893131" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.other.pic.422455567" name="Position Independent Code (-fPIC)" superClass="gnu.cpp.compiler.option.other.pic" value="true" valueType="boolean"/>
<option id="gnu.cpp.compiler.option.warnings.toerrors.1248451962" name="Warnings as errors (-Werror)" superClass="gnu.cpp.compiler.option.warnings.toerrors" value="true" valueType="boolean"/>
<option id="gnu.cpp.compiler.option.debugging.gprof.187786735" superClass="gnu.cpp.compiler.option.debugging.gprof" value="true" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.368497304" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.294424285" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker">
<option defaultValue="true" id="gnu.c.link.option.shared.1511984283" name="Shared (-shared)" superClass="gnu.c.link.option.shared" valueType="boolean"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1969822189" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
<option defaultValue="true" id="gnu.cpp.link.option.shared.1121663668" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared" valueType="boolean"/>
<option id="gnu.cpp.link.option.soname.8564890" superClass="gnu.cpp.link.option.soname" value="libI2C.so.0" valueType="string"/>
<option id="gnu.cpp.link.option.soname.8564890" name="Shared object name (-Wl,-soname=)" superClass="gnu.cpp.link.option.soname" value="libI2C.so.0" valueType="string"/>
<option id="gnu.cpp.link.option.flags.1594520991" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="-pg" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.788150597" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
Expand Down
6 changes: 3 additions & 3 deletions src/I2CDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ I2CDevice::I2CDevice(int bus, int address) {
}

I2CDevice::~I2CDevice() {
// TODO Auto-generated destructor stub

}
//! Read a single byte from I2C Bus
/*!
Expand All @@ -62,7 +62,7 @@ uint8_t I2CDevice::read_byte(int fd, uint8_t address) {
return 0;

}
//! Write a single byte from PCA9685
//! Write a single byte from a I2C Device
/*!
\param fd file descriptor for I/O
\param address register address to write to
Expand All @@ -78,7 +78,7 @@ void I2CDevice::write_byte(int fd, uint8_t address, uint8_t data) {
syslog(LOG_DEBUG, "Wrote to I2C Slave 0x%x @ register 0x%x [0x%x]", _i2caddr, address, data);
}
}
//! Open device file for PCA9685 I2C bus
//! Open device file for I2C Device
/*!
\return fd returns the file descriptor number or -1 on error
*/
Expand Down
8 changes: 4 additions & 4 deletions src/I2CDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class I2CDevice {
public:
I2CDevice(int, int);
virtual ~I2CDevice();
private:
int _i2caddr;
int _i2cbus;
char busfile[64];
uint8_t dataBuffer[BUFFER_SIZE];
uint8_t read_byte(int, uint8_t);
void write_byte(int, uint8_t, uint8_t);
int openfd();
private:
int _i2caddr;
int _i2cbus;
char busfile[64];
};

#endif /* I2CDEVICE_H_ */
19 changes: 19 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#CXX := g++
CXX := arm-unknown-linux-gnueabi-g++
CXXFLAGS := -fPIC -O3 -g -Wall -Werror -pg
MAJOR := 0
MINOR := 1
NAME := I2C
VERSION := $(MAJOR).$(MINOR)

lib: lib$(NAME).so.$(VERSION) lib$(NAME).so

lib$(NAME).so: lib$(NAME).so.$(VERSION)
ldconfig -v -n .
ln -s lib$(NAME).so.$(MAJOR) lib$(NAME).so

lib$(NAME).so.$(VERSION): $(NAME)Device.o
$(CXX) $(CXXFLAGS) -shared -Wl,-soname,lib$(NAME).so.$(MAJOR) $^ -o $@

clean:
$(RM) *.o *.so*

0 comments on commit 5f59296

Please sign in to comment.